﻿<%@ Page Title="Manage Downloads | Hardwares-R-Us" Language="C#" MasterPageFile="~/Main.Master"
    Theme="Admin_User_Theme" AutoEventWireup="true" CodeBehind="ManageDownloads.aspx.cs"
    Inherits="WDTAsg2.Admin.ManageDownloads" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h1>
        Download Management Page</h1>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ListView ID="lvDownloads" runat="server" OnItemCanceling="lvDownloads_ItemCanceling"
                OnItemDeleting="lvDownloads_ItemDeleting" OnItemEditing="lvDownloads_ItemEditing"
                OnItemInserting="lvDownloads_ItemInserting" OnItemUpdating="lvDownloads_ItemUpdating"
                InsertItemPosition="FirstItem">
                <LayoutTemplate>
                    <table id="tblProducts">
                        <tr id="Tr1" runat="server">
                            <th id="Th2" runat="server">
                                Title
                            </th>
                            <th id="Th3" runat="server">
                                Description
                            </th>
                            <th id="Th4" runat="server">
                                Category
                            </th>
                            <th id="Th5" runat="server">
                                DownloadUrl
                            </th>
                            <th id="Th1" colspan="2" runat="server">
                                Actions
                            </th>
                        </tr>
                        <tr runat="server" id="itemPlaceholder" />
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr runat="server">
                        <td>
                            <asp:Label ID="DownloadIdLabel" runat="server" Text='<%# Eval("DownloadId") %>' Visible="false" />
                            <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                        </td>
                        <td style="width: 200px;">
                            <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                        </td>
                        <td>
                            <asp:Label ID="CategoryId" runat="server" Text='<%# Eval("CategoryId") %>' />
                        </td>
                        <td>
                            <a href="<%# Eval("DownloadUrl") %>">Download...</a>
                        </td>
                        <td style="width: 150px;">
                            <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                            <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Do you want to delete?')" />
                        </td>
                    </tr>
                </ItemTemplate>
                <EditItemTemplate>
                    <tr runat="server">
                        <td>
                            <asp:Label ID="DownloadIdLabel" Visible="false" runat="server" Text='<%# Bind("DownloadId") %>' />
                            <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
                        </td>
                        <td>
                            <asp:DropDownList ID="ddCategoryId" DataValueField="CategoryId" DataSourceID="odsCategories"
                                DataTextField="Description" SelectedValue='<%# Bind("CategoryId") %>' runat="server" />
                        </td>
                        <td>
                            <asp:TextBox ID="DownloadUrlTextBox" runat="server" Text='<%# Bind("DownloadUrl") %>' />
                        </td>
                        <td>
                            <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                        </td>
                    </tr>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <tr runat="server">
                        <td>
                            <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
                        </td>
                        <td>
                            <asp:DropDownList ID="ddCategoryId" DataValueField="CategoryId" DataSourceID="odsCategories"
                                DataTextField="Description" SelectedValue='<%# Bind("CategoryId") %>' runat="server" />
                        </td>
                        <td>
                            <asp:TextBox ID="DownloadUrlTextBox" runat="server" Text='<%# Bind("DownloadUrl") %>' />
                        </td>
                        <td>
                            <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                        </td>
                    </tr>
                </InsertItemTemplate>
            </asp:ListView>
            <asp:ObjectDataSource ID="odsCategories" runat="server" SelectMethod="GetAllChildCategories"
                TypeName="WDTAsg2.DbBizObject.CategoryInfo"></asp:ObjectDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>
    <br />
</asp:Content>
